package com.day2.t1;

public class Main {
    public int deleteAndEarn(int[] nums) {
        int[] sum=new int[10001];
        for(int num:nums){
            sum[num]+=num;
        }
        int first=sum[0],second=Math.max(sum[0],sum[1]);
        //就是不能连续
        for (int i = 2; i <sum.length ; i++) {
            int temp=second;
            second=Math.max(second,first+sum[i]);
            first=temp;
        }
        return second;
    }
}
